package com.sky.mapper;

import com.sky.dto.DataQueryDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.List;

@Mapper
public interface ReportMapper1 {

    @Select("select distinct name from sky_take_out.order_detail where order_id in (select id from sky_take_out.orders where date(order_time) =#{end}) group by name  order by count(number) desc")
    List<String> selectTop10NameDay(String begin, String end);

    @Select("select count(number) from sky_take_out.order_detail where order_id in (select id from sky_take_out.orders where date(order_time) =#{end}) group by name  order by count(number) desc")
    List<String> selectTop10NumberDay(String begin,String end);

    @Select("select distinct name from sky_take_out.order_detail where order_id in (select id from sky_take_out.orders where date(order_time) between #{begin} and #{end} ) group by name  order by count(number) desc")
    List<String> selectTop10NameDays(String begin, String end);

    @Select("select count(number) from sky_take_out.order_detail where order_id in (select id from sky_take_out.orders where date(order_time) between #{begin} and #{end} ) group by order_detail.name  order by count(number) desc")
    List<String> selectTop10NumberDays(String begin, String end);

    @Select("select count(*) from sky_take_out.user where date(create_time)=#{format}")
    String selectUserStatisticNew(String format);

    @Select("select count(*) from sky_take_out.user where date(create_time)<=#{end}")
    String selectUserStatisticsAll(String end);

    @Select("select sum(amount) from sky_take_out.orders where date (order_time)>= #{begin} and date (order_time)<= #{end} and status = 5")
    BigDecimal getAllBusinessAmount(DataQueryDTO dataQueryDTO);
}
